<%@ Page Language="C#" AutoEventWireup="true" CodeFile="travel-quote.aspx.cs" Inherits="travel_travel_quote"
    MasterPageFile="~/travel/MobileTravel.master" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/controls/usrIdNumber.ascx" TagName="usrIdNumber" TagPrefix="uc1" %>
<%@ Register Src="~/controls/usrDate.ascx" TagName="usrDate" TagPrefix="uc2" %>
<%@ Register Src="~/controls/usrPhoneNo.ascx" TagName="usrPhoneNo" TagPrefix="uc10" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<form id="form1" runat="server">
<section>
<header id="header">
<nav id="nav">
<a href="../default.aspx"><div class="branding"></div></a>
<div class="navpages">
<a href="../default.aspx">
<asp:Image ID="imgTop" runat="server" ImageUrl="../images/button/topnav-back.png" width="49" height="29" border="0" alt="back" BorderWidth="0"  /></a>
</div>
</nav>
</header>
</section>
    <section id="body">
<div class="body">
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
</asp:ScriptManager>    
    <script type="text/javascript" src="../scripts/jquery-1.5.1.js"></script>
    <script type="text/javascript" src="../scripts/jquery.ui.datepicker.js"></script>
    <script type="text/javascript" src="../scripts/jquery.ui.core.js"></script>
    <script type="text/javascript" src="../scripts/jquery.ui.widget.js"></script>
<div class="form">
<div class="top"></div>
<div class="body">
<div class="pad">
                <div>                   
                    <span style="float: right; font-size: 12px; padding-top: 5px;">
                        <asp:HyperLink ID="hplLogin" NavigateUrl="~/login.aspx" runat="server"> &raquo; sign in to view your previous quotes </asp:HyperLink>
                        <asp:HyperLink ID="hplViewSavedQuotes" NavigateUrl="~/user/ViewResultHistory.aspx" runat="server"> &raquo; view previous quotes </asp:HyperLink>
                        <br />
                    </span>
                </div>
                          <asp:ValidationSummary ID="ValidationSummary1" HeaderText="Oops Please complete the form."
                                    runat="server" ValidationGroup="travel_insurance" CssClass="errorSummary" />
                          <input type="hidden" name="snum" id="snum" runat="server" visible="true" />
                          <asp:DropDownList ID="ddlTripType" onchange="ChangeScenario();" runat="server" class="input" Width="233px">
                            <asp:ListItem Selected="True" Value="-1">- your trip type -</asp:ListItem>
                            <asp:ListItem Value="S">Single Trip</asp:ListItem>
                            <asp:ListItem Value="A">Annual Multi-Trip</asp:ListItem>
                          </asp:DropDownList>
                          <asp:RequiredFieldValidator ID="rfvTripType" InitialValue="-1" runat="server" ControlToValidate="ddlTripType" CssClass="validationErrorControl" ErrorMessage="" ValidationGroup="travel_insurance"></asp:RequiredFieldValidator>
                          <asp:DropDownList ID="ddlPolicyType" onchange="ChangeScenario();" runat="server" class="input" Width="233">
                            <asp:ListItem Selected="True" Value="-1">- your type of policy -</asp:ListItem>
                            <asp:ListItem Value="IND">Individual</asp:ListItem>
                            <asp:ListItem Value="INS">Individual + Spouse</asp:ListItem>
                            <asp:ListItem Value="FML">Family</asp:ListItem>
                          </asp:DropDownList>
                          <asp:RequiredFieldValidator ID="rfvPolicyType" InitialValue="-1" runat="server" ControlToValidate="ddlPolicyType" CssClass="validationErrorControl" ErrorMessage="" ValidationGroup="travel_insurance"></asp:RequiredFieldValidator>
                          
                          <asp:DropDownList ID="ddlCoverage"  runat="server" class="input" Width="233">
                                            <asp:ListItem Selected="True" Value="-1">- level of coverage -</asp:ListItem>
                                            <asp:ListItem Value="S">Starter [up to $150,000]</asp:ListItem>
                                            <asp:ListItem Value="I">Intermediate [$150,001 - $250,000]</asp:ListItem>
                                            <asp:ListItem Value="A">Advance [more than $250,000]</asp:ListItem>
                         </asp:DropDownList>
                          <asp:RequiredFieldValidator ID="rfvCoverage" InitialValue="-1" runat="server" ControlToValidate="ddlCoverage" CssClass="validationErrorControl" ErrorMessage=""
                                            ValidationGroup="travel_insurance"></asp:RequiredFieldValidator>
                                   
                         <div id="divSingleTrip" style="display: none">
                             <span style="font-size:x-small;">Traveling from Singapore to: </span><br />
                             <div style="display: none;">
                                <asp:DropDownList ID="ddlDestCountry" runat="server" class="input" Width="233px">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="rfvDestCountry" InitialValue="-1" runat="server" ControlToValidate="ddlDestCountry" CssClass="validationErrorControl" ErrorMessage=""
                                                    ValidationGroup="travel_insurance"></asp:RequiredFieldValidator></div>
                                <asp:TextBox ID="txtCountry" runat="server" Width="233px" AutoCompleteType="Disabled" onfocus="disableautocompletion(this.id);"></asp:TextBox>
                                <div id="divwidth" style="text-align:left; width:233px;">
                                </div>
                                <input id="inputSelCountryName" type="hidden" runat="server" />
                                <asp:RequiredFieldValidator ID="rfvCountry" InitialValue="" runat="server" ControlToValidate="txtCountry" ErrorMessage="" ValidationGroup="travel_insurance" CssClass="validationErrorControl" ></asp:RequiredFieldValidator>
                                <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtCountry" FirstRowSelected="true" MinimumPrefixLength="1"
                                    EnableCaching="true" CompletionSetCount="10" CompletionInterval="100" ServiceMethod="GetCountries" OnClientPopulating="ShowProcessImage" OnClientPopulated="HideProcessImage" OnClientItemSelected="SelectedCountry"
                                    CompletionListCssClass="AutoExtender" CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight" CompletionListElementID="divwidth">
                                </cc1:AutoCompleteExtender>
                                   
                                 <span style="font-size:x-small;">Travel Start Date</span> <br />
                                <input id="from" name="from" type="text" readonly="readonly" style="width:220px;" />
                                <input id="inputFrom" type="hidden" runat="server" />
                                 <span style="font-size:x-small;">Travel End Date</span><br />
                                <input id="to" name="to" type="text" readonly="readonly" style="width:220px;" />
                                <input id="inputTo" type="hidden" runat="server" />
                                       
                            </div>
                            
                            <div id="divAnnualTrip" style="display: none"> 
                            <asp:DropDownList ID="ddlDestRegion" runat="server" class="input" Width="233" >
                            </asp:DropDownList>
                             <asp:RequiredFieldValidator ID="rfvDestRegion" InitialValue="-1" runat="server" ControlToValidate="ddlDestRegion" CssClass="validationErrorControl" ErrorMessage="" ValidationGroup="travel_insurance"></asp:RequiredFieldValidator>
                             
                            <span style="font-size:x-small;">Policy Commencement Date</span> <br />
                           <input id="annualcomdate" name="annualcomdate" type="text" readonly="readonly" class="input" style="width:233;" />
                           <input id="inputannualcomdate" type="hidden" runat="server" />                                      
                            </div>
                            
                            <div id="divIndividual" style="display: none">
                             Birthday <br />
                            <uc2:usrDate ID="usrBirthday" ValidationGroup="travel_insurance" runat="server" />                            
                            </div>
                            
                            <div id="divIndividualSpouse" style="display: none">
                             Spouse's Birthday <br /><uc2:usrDate ID="usrBirthdaySpouse" ValidationGroup="travel_insurance" runat="server" />                                       
                            </div>
                            
                            <div id="divFamily" style="display: none">
                                <div id="divNoOfAdults">
                                <asp:DropDownList ID="ddlNoOfAdults" onchange="AdultDOBShowHide();AdultDOBValidation();"
                                                runat="server" class="text">
                                                <asp:ListItem Selected="True" Value="0">- number of adults -</asp:ListItem>
                                                <asp:ListItem Value="1">1</asp:ListItem>
                                                <asp:ListItem Value="2">2</asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="rfvNoOfAdults" InitialValue="0" runat="server" ControlToValidate="ddlNoOfAdults" CssClass="validationErrorControl" ErrorMessage="" ValidationGroup="travel_insurance"></asp:RequiredFieldValidator>
                                </div>
                                
                                <div id="divAdult1">
                                  <span style="font-size:x-small;">Date of Birth (Adult 1)</span> <br />
                                 <uc2:usrDate ID="usrAdult1DOB" ValidationGroup="travel_insurance" runat="server" />                                      
                                </div>
                                <div id="divAdult2">                                   
                                 <span style="font-size:x-small;">Date of Birth (Adult 2)</span> <br />
                                <uc2:usrDate ID="usrAdult2DOB" ValidationGroup="travel_insurance" runat="server" />
                                </div>
                                <div id="divNoOfChild">
                                  <span style="font-size:x-small;">No of Children:</span><br />
                                  <span style="font-size:x-small;">(Child 18-25 must be full-time student)</span>
                                 <asp:DropDownList ID="ddlNoOfChilds" onchange="ChildDOBShowHide();ChildDOBValidation();"
                                                runat="server" class="text">
                                                <asp:ListItem Selected="True" Value="0">- select no of child-</asp:ListItem>
                                                <asp:ListItem Value="1">1</asp:ListItem>
                                                <asp:ListItem Value="2">2</asp:ListItem>
                                                <asp:ListItem Value="3">3</asp:ListItem>
                                                <asp:ListItem Value="4">4</asp:ListItem>
                                                <asp:ListItem Value="5">5</asp:ListItem>
                                                <asp:ListItem Value="6">6</asp:ListItem>
                                 </asp:DropDownList>
                                 <asp:RequiredFieldValidator ID="rfvNoOfChilds" InitialValue="0" runat="server" ControlToValidate="ddlNoOfChilds" CssClass="validationErrorControl" ErrorMessage="" ValidationGroup="travel_insurance"></asp:RequiredFieldValidator>
                                </div>
                                <div id="divChild1">                                
                                  <span style="font-size:x-small;">Date of Birth (Child 1)</span>
                                 <uc2:usrDate ID="usrChild1DOB" ValidationGroup="travel_insurance" runat="server" />
                                
                                </div>
                                <div id="divChild2">
                                     <span style="font-size:x-small;">Date of Birth (Child 2)</span>    
                                   <uc2:usrDate ID="usrChild2DOB" ValidationGroup="travel_insurance" runat="server" />                                   
                                </div>
                                <div id="divChild3">
                                     <span style="font-size:x-small;">Date of Birth (Child 3)</span>
                                    <uc2:usrDate ID="usrChild3DOB" ValidationGroup="travel_insurance" runat="server" />                                    
                                </div>
                                <div id="divChild4">                                    
                                     <span style="font-size:x-small;">Date of Birth (Child 4)</span>
                                            <uc2:usrDate ID="usrChild4DOB" ValidationGroup="travel_insurance" runat="server" />
                                </div>
                                <div id="divChild5">                                    
                                    <span style="font-size:x-small;">Date of Birth (Child 5)</span>
                                            <uc2:usrDate ID="usrChild5DOB" ValidationGroup="travel_insurance" runat="server" />
                                </div>
                                <div id="divChild6">
                                     <span style="font-size:x-small;">Date of Birth (Child 6)</span>
                                            <uc2:usrDate ID="usrChild6DOB" ValidationGroup="travel_insurance" runat="server" />                                    
                                </div>
                            </div>
                            
                            <div id="divFamilySingle" style="display: none">
                                <div id="divNoOfAdultsSingle">                                    
                                      <span style="font-size:x-small;">Number of adults</span>
                                            <asp:DropDownList ID="ddlNoOfAdultsSingle" onchange="AdultDOBSingleShowHide();AdultDOBSingleValidation();"
                                                runat="server" class="text">
                                                <asp:ListItem Selected="True" Value="0">Select</asp:ListItem>
                                                <asp:ListItem Value="1">1</asp:ListItem>
                                                <asp:ListItem Value="2">2</asp:ListItem>
                                            </asp:DropDownList>
                                            <asp:RequiredFieldValidator ID="rfvNoOfAdultsSingle" InitialValue="0" runat="server"
                                                ControlToValidate="ddlNoOfAdultsSingle" CssClass="validationErrorControl" ErrorMessage=""
                                                ValidationGroup="travel_insurance"></asp:RequiredFieldValidator>
                                </div>
                                <div id="divAdultSingle1">
                                        <span style="font-size:x-small;">Date of Birth (Adult 1)</span>
                                            <uc2:usrDate ID="usrAdult1DOBSingle" ValidationGroup="travel_insurance" runat="server" />
                                </div>
                                <div  id="divAdultSingle2">                            
                                         <span style="font-size:x-small;">Date of Birth (Adult 2)</span>
                                            <uc2:usrDate ID="usrAdult2DOBSingle" ValidationGroup="travel_insurance" runat="server" />
                                </div>
                                <div id="divNoOfChildSingle">
                                         <span style="font-size:x-small;">No of Children:</span><br />
                                         <span style="font-size:x-small;">(Child 18-25 must be full-time student)</span>
                                  <asp:DropDownList ID="ddlNoOfChildsSingle" onchange="ChildDOBSingleShowHide();ChildDOBSingleValidation();"
                                                runat="server" class="text">
                                                <asp:ListItem Selected="True" Value="0">Select</asp:ListItem>
                                                <asp:ListItem Value="1">1</asp:ListItem>
                                                <asp:ListItem Value="2">2</asp:ListItem>
                                                <asp:ListItem Value="3">3</asp:ListItem>
                                                <asp:ListItem Value="4">4</asp:ListItem>
                                  </asp:DropDownList>
                                  <asp:RequiredFieldValidator ID="rfvNoOfChildsSingle" InitialValue="0" runat="server"
                                                ControlToValidate="ddlNoOfChildsSingle" CssClass="validationErrorControl" ErrorMessage=""
                                                ValidationGroup="travel_insurance"></asp:RequiredFieldValidator>
                                        
                                </div>
                                <div id="divChildSingle1">
                                    <span style="font-size:x-small;">Date of Birth (Child 1)</span>
                                   <uc2:usrDate ID="usrChild1DOBSingle" ValidationGroup="travel_insurance" runat="server" />                                   
                                </div>
                                <div id="divChildSingle2">
                                         <span style="font-size:x-small;">Date of Birth (Child 2)</span>
                                    <uc2:usrDate ID="usrChild2DOBSingle" ValidationGroup="travel_insurance" runat="server" />                                    
                                </div>
                                <div id="divChildSingle3">                                    
                                         <span style="font-size:x-small;">Date of Birth (Child 3)</span>
                                        <uc2:usrDate ID="usrChild3DOBSingle" ValidationGroup="travel_insurance" runat="server" />                                        
                                </div>
                                <div id="divChildSingle4">
                                         <span style="font-size:x-small;">Date of Birth (Child 4)</span>
                                            <uc2:usrDate ID="usrChild4DOBSingle" ValidationGroup="travel_insurance" runat="server" />
                                </div>
                            </div>
                            <br />
                            <asp:TextBox ID="txtName" Width="222" MaxLength="50" runat="server" Text="Your Name" CssClass="input"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvFirstName" runat="server" CssClass="validationErrorControl" ValidationGroup="travel_insurance" ErrorMessage="" Text="" ControlToValidate="txtName" InitialValue="Your Name" Display="Dynamic"></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="revFirstName" runat="server" ValidationGroup="travel_insurance" ValidationExpression="^[a-zA-Z''-'\s]{1,50}$" CssClass="validationErrorControl" ControlToValidate="txtName" ErrorMessage="" Display="Dynamic"></asp:RegularExpressionValidator>
                            <div id="divSpouse" style="display:none;">
                            <asp:TextBox ID="txtSpouseName" Width="222" MaxLength="50" runat="server" Text="Your Spouse Name" CssClass="input"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvSpouseName" runat="server" CssClass="validationErrorControl" ValidationGroup="travel_insurance" ErrorMessage="" Text="" ControlToValidate="txtSpouseName" InitialValue="Your Spouse Name" Display="Dynamic" ></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="revSpouseName" runat="server" ValidationGroup="travel_insurance" ValidationExpression="^[a-zA-Z''-'\s]{1,50}$" CssClass="validationErrorControl" ControlToValidate="txtSpouseName" ErrorMessage="" Display="Dynamic" ></asp:RegularExpressionValidator>
                            </div>
                            <html5:EmailInput ID="txtEmailAddress" runat="server" MaxLength="100" Width="222px" CssClass="input" Text="Your Email">
                                    </html5:EmailInput>
                             <asp:RequiredFieldValidator ID="rfvEmail" runat="server" Text="" CssClass="validationErrorControl" ValidationGroup="travel_insurance" ErrorMessage="" ControlToValidate="txtEmailAddress" Display="Dynamic"></asp:RequiredFieldValidator>
                             <asp:RegularExpressionValidator ID="rfvEmailValid" Text="" CssClass="validationErrorControl" runat="server" ValidationGroup="travel_insurance" ErrorMessage="" ControlToValidate="txtEmailAddress" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"></asp:RegularExpressionValidator>
                              <uc10:usrPhoneNo ID="txtMobileNo" ValidationGroup="travel_insurance" IsEnabled="true" PhoneNoErrorMessage="Mobile Phone No must be number value."
                                        PhoneNoValidErrorMessage="Mobile phone no is not valid." IsRequired="true" PhoneNoRequireErrorMessage="Require Mobile Phone No."
                                        runat="server" />
                              <%--<span style="font-size:x-small;">NRIC/FIN</span><br />
                             <uc1:usrIdNumber ID="usrNRIC" runat="server" ValidationGroup="travel_insurance" />--%>
                             <br />
                             <asp:Button runat="server" ID="btnNext" CssClass="apply" ValidationGroup="travel_insurance" OnClientClick="LoadValidationErrorCss();"
                                    OnClick="imgbtnSearch_Click" BorderWidth="0" />
                                    <br />
                                    
    <div id="divLoggedin" runat="server" >
    <br />
    <asp:ImageButton ID="imgbtnLogout" runat="server" ImageUrl="~/images/button/logout.png" Visible="false" OnClick="imgbtnLogout_Click" />
    <hr />
    </div>
</div>
</div>
</div>
<div class="bottom"></div>
</div>
</section>
    </form>

    <script type="text/javascript">
        //<![CDATA[

        //        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
        //        function endRequestHandler() {
        //            javascript:JT_init();
        //        }

        /*function JT_init() {
        $("a.jTip")
        .hover(function() { JT_show(this.href, this.id, this.name) }, function() { $('#JT').remove() })
        .click(function() { return false });
        }*/

        function ShowHideDiv(divName, varOnOff) {
            if (varOnOff) {
                document.getElementById(divName).style.display = "";
            }
            else {
                document.getElementById(divName).style.display = "none";
            }
        }

        function SingleTripValidationState(onOff) {
            ValidatorEnable(document.getElementById('<%=rfvDestCountry.ClientID%>'), onOff);
            ValidatorEnable(document.getElementById('<%=rfvCountry.ClientID%>'), onOff);


        }

        function AnnualTripValidationState(onOff) {
            ValidatorEnable(document.getElementById('<%=rfvDestRegion.ClientID%>'), onOff);

        }

        function IndividualValidationState(onOff) {
            IsEnableDateValidation('<%=usrBirthday.ClientID%>', onOff);

        }

        function IndividualSpouseValidationState(onOff) {
            IsEnableDateValidation('<%=usrBirthday.ClientID%>', onOff);
            IsEnableDateValidation('<%=usrBirthdaySpouse.ClientID%>', onOff);

            ShowHideDiv('divSpouse', onOff);
            ValidatorEnable(document.getElementById('<%=rfvSpouseName.ClientID%>'), onOff);
            ValidatorEnable(document.getElementById('<%=revSpouseName.ClientID%>'), onOff);
        }

        function FamilyValidationState(onOff) {
            ValidatorEnable(document.getElementById('<%=rfvNoOfAdults.ClientID%>'), onOff);
            document.getElementById('<%=ddlNoOfAdults.ClientID%>').value = "-1";
            AdultDOBShowHide();
            AdultDOBValidation();

            ValidatorEnable(document.getElementById('<%=rfvNoOfChilds.ClientID%>'), onOff);
            document.getElementById('<%=ddlNoOfChilds.ClientID%>').value = "-1";
            ChildDOBShowHide();
            ChildDOBValidation();

        }

        function FamilySingleTripValidationState(onOff) {
            ValidatorEnable(document.getElementById('<%=rfvNoOfAdultsSingle.ClientID%>'), onOff);
            document.getElementById('<%=ddlNoOfAdultsSingle.ClientID%>').value = "-1";
            AdultDOBSingleShowHide();
            AdultDOBSingleValidation();


            ValidatorEnable(document.getElementById('<%=rfvNoOfChildsSingle.ClientID%>'), onOff);
            document.getElementById('<%=ddlNoOfChildsSingle.ClientID%>').value = "-1";

            ChildDOBSingleShowHide();
            ChildDOBSingleValidation();
        }

        function AdultDOBValidation() {
            var _count = document.getElementById('<%=ddlNoOfAdults.ClientID%>').value;

            var usrAdult1DOB = "<%=usrAdult1DOB.ClientID%>";
            var usrAdult2DOB = "<%=usrAdult2DOB.ClientID%>";

            if (_count == 0 || document.getElementById('divFamily').style.display == 'none') {
                IsEnableDateValidation(usrAdult1DOB, false);
                IsEnableDateValidation(usrAdult2DOB, false);

            }
            else {
                for (var i = 1; i <= 3; i++) {
                    if (_count > 0) IsEnableDateValidation(usrAdult1DOB, true);
                    else IsEnableDateValidation(usrAdult1DOB, false);

                    if (_count > 1) IsEnableDateValidation(usrAdult2DOB, true);
                    else IsEnableDateValidation(usrAdult2DOB, false);

                }
            }
        }

        function AdultDOBSingleValidation() {
            var _count = document.getElementById('<%=ddlNoOfAdultsSingle.ClientID%>').value;

            var usrAdult1DOB = "<%=usrAdult1DOBSingle.ClientID%>";
            var usrAdult2DOB = "<%=usrAdult2DOBSingle.ClientID%>";

            if (_count == 0 || document.getElementById('divFamilySingle').style.display == 'none') {
                IsEnableDateValidation(usrAdult1DOB, false);
                IsEnableDateValidation(usrAdult2DOB, false);

            }
            else {
                for (var i = 1; i <= 3; i++) {
                    if (_count > 0) IsEnableDateValidation(usrAdult1DOB, true);
                    else IsEnableDateValidation(usrAdult1DOB, false);

                    if (_count > 1) IsEnableDateValidation(usrAdult2DOB, true);
                    else IsEnableDateValidation(usrAdult2DOB, false);

                }
            }
        }

        function ChildDOBValidation() {
            var _count = document.getElementById('<%=ddlNoOfChilds.ClientID%>').value;

            var usrChild1DOB = "<%=usrChild1DOB.ClientID%>";
            var usrChild2DOB = "<%=usrChild2DOB.ClientID%>";
            var usrChild3DOB = "<%=usrChild3DOB.ClientID%>";
            var usrChild4DOB = "<%=usrChild4DOB.ClientID%>";
            var usrChild5DOB = "<%=usrChild5DOB.ClientID%>";
            var usrChild6DOB = "<%=usrChild6DOB.ClientID%>";

            if (_count == 0 || document.getElementById('divFamily').style.display == 'none') {
                IsEnableDateValidation(usrChild1DOB, false);
                IsEnableDateValidation(usrChild2DOB, false);
                IsEnableDateValidation(usrChild3DOB, false);
                IsEnableDateValidation(usrChild4DOB, false);
                IsEnableDateValidation(usrChild5DOB, false);
                IsEnableDateValidation(usrChild6DOB, false);

            }
            else {
                for (var i = 1; i <= 6; i++) {
                    if (_count > 0) IsEnableDateValidation(usrChild1DOB, true);
                    else IsEnableDateValidation(usrChild1DOB, false);

                    if (_count > 1) IsEnableDateValidation(usrChild2DOB, true);
                    else IsEnableDateValidation(usrChild2DOB, false);

                    if (_count > 2) IsEnableDateValidation(usrChild3DOB, true);
                    else IsEnableDateValidation(usrChild3DOB, false);

                    if (_count > 3) IsEnableDateValidation(usrChild4DOB, true);
                    else IsEnableDateValidation(usrChild4DOB, false);

                    if (_count > 4) IsEnableDateValidation(usrChild5DOB, true);
                    else IsEnableDateValidation(usrChild5DOB, false);

                    if (_count > 5) IsEnableDateValidation(usrChild6DOB, true);
                    else IsEnableDateValidation(usrChild6DOB, false);
                }
            }
        }

        function ChildDOBSingleValidation() {
            var _count = document.getElementById('<%=ddlNoOfChildsSingle.ClientID%>').value;

            var usrChild1DOB = "<%=usrChild1DOBSingle.ClientID%>";
            var usrChild2DOB = "<%=usrChild2DOBSingle.ClientID%>";
            var usrChild3DOB = "<%=usrChild3DOBSingle.ClientID%>";
            var usrChild4DOB = "<%=usrChild4DOBSingle.ClientID%>";

            if (_count == 0 || document.getElementById('divFamilySingle').style.display == 'none') {
                IsEnableDateValidation(usrChild1DOB, false);
                IsEnableDateValidation(usrChild2DOB, false);
                IsEnableDateValidation(usrChild3DOB, false);
                IsEnableDateValidation(usrChild4DOB, false);
            }
            else {
                for (var i = 1; i <= 5; i++) {
                    if (_count > 0) IsEnableDateValidation(usrChild1DOB, true);
                    else IsEnableDateValidation(usrChild1DOB, false);

                    if (_count > 1) IsEnableDateValidation(usrChild2DOB, true);
                    else IsEnableDateValidation(usrChild2DOB, false);

                    if (_count > 2) IsEnableDateValidation(usrChild3DOB, true);
                    else IsEnableDateValidation(usrChild3DOB, false);

                    if (_count > 3) IsEnableDateValidation(usrChild4DOB, true);
                    else IsEnableDateValidation(usrChild4DOB, false);

                }
            }
        }

        function AdultDOBShowHide() {
            var _count = document.getElementById('<%=ddlNoOfAdults.ClientID%>').value;
            //alert(_count);
            for (var i = 1; i <= 2; i++) {
                if (_count >= i)
                    ShowHideDiv('divAdult' + i.toString(), true);
                else
                    ShowHideDiv('divAdult' + i.toString(), false);
            }
        }

        function AdultDOBSingleShowHide() {
            var _count = document.getElementById('<%=ddlNoOfAdultsSingle.ClientID%>').value;
            //alert(_count);
            for (var i = 1; i <= 2; i++) {
                if (_count >= i)
                    ShowHideDiv('divAdultSingle' + i.toString(), true);
                else
                    ShowHideDiv('divAdultSingle' + i.toString(), false);
            }
        }

        function ChildDOBShowHide() {
            var _count = document.getElementById('<%=ddlNoOfChilds.ClientID%>').value;
            //alert(_count);
            for (var i = 1; i <= 6; i++) {
                if (_count >= i)
                    ShowHideDiv('divChild' + i.toString(), true);
                else
                    ShowHideDiv('divChild' + i.toString(), false);
            }
        }

        function ChildDOBSingleShowHide() {
            var _count = document.getElementById('<%=ddlNoOfChildsSingle.ClientID%>').value;
            //alert(_count);
            for (var i = 1; i <= 4; i++) {
                if (_count >= i)
                    ShowHideDiv('divChildSingle' + i.toString(), true);
                else
                    ShowHideDiv('divChildSingle' + i.toString(), false);
            }
        }

        function ChangeScenario() {
            var ddlTripType = document.getElementById('<%=ddlTripType.ClientID%>');
            var ddlPolicyType = document.getElementById('<%=ddlPolicyType.ClientID%>');

            ShowHideDiv('divSingleTrip', false);
            ShowHideDiv('divAnnualTrip', false);
            ShowHideDiv('divIndividual', false);
            ShowHideDiv('divIndividualSpouse', false);
            ShowHideDiv('divFamily', false);
            ShowHideDiv('divFamilySingle', false);
            ShowHideDiv('divSpouse', false);
            
            SingleTripValidationState(false);
            AnnualTripValidationState(false);
            IndividualValidationState(false);
            IndividualSpouseValidationState(false);
            FamilyValidationState(false);
            FamilySingleTripValidationState(false);

            if (ddlTripType.value == 'S') {

                ShowHideDiv('divSingleTrip', true);
                SingleTripValidationState(true);
                //document.getElementById('<%=snum.ClientID%>').value = '1';
                //alert(document.getElementById('<%=inputFrom.ClientID%>').value);
                if (document.getElementById('<%=inputFrom.ClientID%>').value != '') {
                    document.getElementById('from').value = document.getElementById('<%=inputFrom.ClientID%>').value;
                }

                if (document.getElementById('<%=inputTo.ClientID%>').value != '') {
                    document.getElementById('to').value = document.getElementById('<%=inputTo.ClientID%>').value;
                }

                if (document.getElementById('<%=inputSelCountryName.ClientID%>').value != "") {
                    document.getElementById('<%=txtCountry.ClientID%>').value = document.getElementById('<%=inputSelCountryName.ClientID%>').value;
                }
            }
            else if (ddlTripType.value == 'A') {

                ShowHideDiv('divAnnualTrip', true);
                AnnualTripValidationState(true);

                if (document.getElementById('<%=inputFrom.ClientID%>').value != '') {
                    document.getElementById('annualcomdate').value = document.getElementById('<%=inputannualcomdate.ClientID%>').value;
                }

                //document.getElementById('<%=snum.ClientID%>').value = '2';
                //alert('test ' + document.getElementById('<%=snum.ClientID%>').value);
            }

            if (ddlPolicyType.value == 'IND') {

                ShowHideDiv('divIndividual', true);
                IndividualValidationState(true);
            }
            else if (ddlPolicyType.value == 'FML') {

                if (ddlTripType.value == 'S') {
                    ShowHideDiv('divFamilySingle', true);
                    FamilySingleTripValidationState(true);
                }
                else {
                    ShowHideDiv('divFamily', true);
                    FamilyValidationState(true);
                }

            }
            else if (ddlPolicyType.value == 'INS') {
                ShowHideDiv('divIndividual', true);
                ShowHideDiv('divIndividualSpouse', true);
                IndividualSpouseValidationState(true);

            }

        }

        function PhoneNoLengthClientValidate(source, arguments) {
            if (arguments.Value.length != 0 && arguments.Value.length < 8) {
                arguments.IsValid = false;
            } else {
                arguments.IsValid = true;
            }
        }

        function CheckPhoneNoClientValidate(source, arguments) {
            var cval = parseInt(arguments.Value)
            if (isNaN(cval)) {
                arguments.IsValid = false;
            } else {
                var cstrVal = "" + cval + "";
                if (cstrVal.length < 8) {
                    arguments.IsValid = false;
                }
                else if (cstrVal.charAt(0) != "6" &&
                    cstrVal.charAt(0) != "8" &&
                    cstrVal.charAt(0) != "9") {
                    arguments.IsValid = false;
                }
                else {
                    arguments.IsValid = true;
                }
            }
        }


        window.onload = function() {
            ChangeScenario();

            /*usrStart = 'ctl00_ContentPlaceHolder1_usrTravelStartDate_';
            var startDay = document.getElementById(usrStart + 'ddlDay');
            var startMon = document.getElementById(usrStart + 'ddlMonth');
            var startYr = document.getElementById(usrStart + 'ddlYear');

            usrEnd = 'ctl00_ContentPlaceHolder1_usrTravelEndDate_';
            var endDay = document.getElementById(usrEnd + 'ddlDay');
            var endMon = document.getElementById(usrEnd + 'ddlMonth');
            var endYr = document.getElementById(usrEnd + 'ddlYear');

            //alert(startDay.value);

            startDay.onchange = function()
            { UpdateEndDate('1'); }

            startMon.onchange = function()
            { UpdateEndDate('1'); }

            startYr.onchange = function()
            { UpdateEndDate('1'); }

            endDay.onchange = function()
            { UpdateEndDate('0'); }

            endMon.onchange = function()
            { UpdateEndDate('0'); }

            endYr.onchange = function()
            { UpdateEndDate('0'); }
            */


        }

        /*function UpdateEndDate(isStart) {

            usrStart = 'ctl00_ContentPlaceHolder1_usrTravelStartDate_';
        usrEnd = 'ctl00_ContentPlaceHolder1_usrTravelEndDate_';

           var startDay = document.getElementById(usrStart + 'ddlDay');
        var startMon = document.getElementById(usrStart + 'ddlMonth');
        var startYr = document.getElementById(usrStart + 'ddlYear');

            var endDay = document.getElementById(usrEnd + 'ddlDay');
        var endMon = document.getElementById(usrEnd + 'ddlMonth');
        var endYr = document.getElementById(usrEnd + 'ddlYear');

            var startdate = new Date(startYr.value, startMon.value - 1, startDay.value);
        var enddate = new Date(endYr.value, endMon.value - 1, endDay.value);

            var dtnow = new Date();
        var dtnowM = dtnow.getMonth();
        var dtnowY = dtnow.getFullYear();
        var dtnowD = dtnow.getDate();
        var dtToday = new Date(dtnowY, dtnowM, dtnowD);

            if (isStart == '1') {
        if (startdate > dtToday && startdate > enddate) {
        endDay.value = startDay.value;
        endMon.value = startMon.value;
        endYr.value = startYr.value;
        }
        }

            if (isStart == '0') {
        if (enddate < startdate) {
        endDay.value = startDay.value;
        endMon.value = startMon.value;
        endYr.value = startYr.value;
        }
        }
           

        } */

        $(function() {
            var dates = $("#from").datepicker({
                showOn: 'both',
                buttonImage: '../images/icon/calendar.gif',
                buttonImageOnly: true,
                //showAnim: 'slideDown',
                defaultDate: "+1w",
                changeMonth: true,
                numberOfMonths: 2,
                dateFormat: "dd/mm/yy",
                //minDate: '+1d',
                beforeShow: setFromRange,
                onSelect: function(selectedDate) {
                    var option = this.id == "from" ? "minDate" : "maxDate",
					instance = $(this).data("datepicker"),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings);
                    dates.not(this).datepicker("option", option, date);

                }
            });

            var dates = $("#to").datepicker({
                showOn: 'both',
                buttonImage: '../images/icon/calendar.gif',
                buttonImageOnly: true,
                defaultDate: "+1w",
                changeMonth: true,
                numberOfMonths: 2,
                dateFormat: "dd/mm/yy",
                //minDate: '+1d',
                beforeShow: setToRange,
                onSelect: function(selectedDate) {
                    var option = this.id == "from" ? "minDate" : "maxDate",
					instance = $(this).data("datepicker"),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings);
                    dates.not(this).datepicker("option", option, date);
                }
            });


            function setToRange() {

                var next183Days;
                next183Days = $("#from").datepicker('getDate');
                next183Days.setDate(next183Days.getDate() + 182);

                var minDate = $("#from").datepicker('getDate');
                var maxDate = next183Days;

                return {

                    minDate: minDate,
                    maxDate: maxDate

                }

            }

            function setFromRange() {

                var fullDate = new Date();
                fullDate.setDate(fullDate.getDate() + 1);

                var min183Days;
                min183Days = $("#to").datepicker('getDate');
                min183Days.setDate(min183Days.getDate() - 183);

                var minDate = min183Days;
                var maxDate = $("#to").datepicker('getDate');

                if (min183Days < fullDate) {
                    minDate = fullDate;
                }


                return {

                    minDate: minDate
                    //maxDate: maxDate

                }

            }

        });

        $(function() {
            var dates = $("#annualcomdate").datepicker({
                showOn: 'both',
                buttonImage: '/images/icon/calendar.gif',
                buttonImageOnly: true,
                defaultDate: "+1w",
                changeMonth: true,
                numberOfMonths: 1,
                dateFormat: "dd/mm/yy",
                minDate: '+1d'

            });
        });



        function ValidateSearchFields() {

            if (document.getElementById('from').value == '') {
                document.getElementById('from').className = 'inputValidation';
                return false;
            }
            else {
                document.getElementById('from').className = '';
            }

            if (document.getElementById('to').value == '') {
                document.getElementById('to').className = 'inputValidation';
                return false;
            }
            else {
                document.getElementById('to').className = '';
            }

            return true
        }

        function checkValidation() {

            if (Page_ClientValidate('travel_insurance')) {

                if (document.getElementById('divSingleTrip').style.display != 'none') {
                    var isvalid = new Boolean(ValidateSearchFields());
                    if (isvalid.toString() == 'true') {
                        document.getElementById('<%=inputFrom.ClientID%>').value = document.getElementById('from').value;
                        document.getElementById('<%=inputTo.ClientID%>').value = document.getElementById('to').value;

                        if (document.getElementById('<%=txtCountry.ClientID%>').value == document.getElementById('<%=inputSelCountryName.ClientID%>').value) {
                            SingleTripValidationState(false);
                            return true;
                        }
                        else {
                            document.getElementById('<%=txtCountry.ClientID%>').className = 'validationError';

                        }
                    }
                }
                else {

                    document.getElementById('<%=inputannualcomdate.ClientID%>').value = document.getElementById('annualcomdate').value;
                    return true;
                }


            }
            else {
                if (document.getElementById('divSingleTrip').style.display != 'none') {
                    if (document.getElementById('<%=txtCountry.ClientID%>').value != document.getElementById('<%=inputSelCountryName.ClientID%>').value) {
                        document.getElementById('<%=txtCountry.ClientID%>').className = 'validationError';
                    }
                }
                return false;
            }

        }

        function ShowProcessImage() {

            var autocomplete = document.getElementById('<%=txtCountry.ClientID%>');
            autocomplete.className = 'inputCountry';
            autocomplete.style.backgroundImage = 'url(../images/loader/small_loading.gif)';
            autocomplete.style.backgroundRepeat = 'no-repeat';
            autocomplete.style.backgroundPosition = 'right';
        }
        function HideProcessImage() {
            var autocomplete = document.getElementById('<%=txtCountry.ClientID%>');
            autocomplete.style.backgroundImage = 'none';
            autocomplete.className = 'inputCountry';
        }

        function SelectedCountry() {
            var autocomplete = document.getElementById('<%=txtCountry.ClientID%>');

            var dd = document.getElementById('<%=ddlDestCountry.ClientID%>');
            for (var i = 0; i < dd.options.length; i++) {
                if (dd.options[i].text === autocomplete.value) {
                    dd.selectedIndex = i;
                    document.getElementById('<%=inputSelCountryName.ClientID%>').value = dd.options[i].text
                    break;
                }
            }
        }

        function disableautocompletion(id) {
            var txtControl = document.getElementById(id);
            txtControl.setAttribute("autocomplete", "off");
        }

        function DefaultName(TextBoxControl, TextBoxEvent) {
            if (TextBoxControl.value.length == 0 && TextBoxEvent.type == "blur") {
                TextBoxControl.value = "Your Name";
            }
        }

        function DefaultSpouseName(TextBoxControl, TextBoxEvent) {
            if (TextBoxControl.value.length == 0 && TextBoxEvent.type == "blur") {
                TextBoxControl.value = "Your Spouse Name";
            }
        }

        function DefaultEmail(TextBoxControl, TextBoxEvent) {
            if (TextBoxControl.value.length == 0 && TextBoxEvent.type == "blur") {
                TextBoxControl.value = "Your Email";
            }
        }


        function ClearText(TextBoxControl, TextBoxEvent) {
            if (TextBoxControl.value == "Your Name") {
                TextBoxControl.value = "";
            }
            if (TextBoxControl.value == "Your Email") {
                TextBoxControl.value = "";
            }

            if (TextBoxControl.value == "Your Mobile") {
                TextBoxControl.value = "";
            }

            if (TextBoxControl.value == "Your Spouse Name") {
                TextBoxControl.value = "";
            }
        }
        //]]>
        
    
    </script>

    <script src="../scripts/CE_Date_travel.js" type="text/javascript"></script>

</asp:Content>
